#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1e5+10;

int n;
int w[N];

bool check(int cnt)
{
    for (int i = 0, s = 0; i < n; i ++ ){
        s += w[i];
        if (s > cnt) return false;
        if (s == cnt) s = 0;
    }
    return true;
}


int main()
{
    int T;
    scanf("%d", &T);
    
    while (T -- ){
        scanf("%d", &n);
        int sum = 0;
        for (int i = 0; i < n; i ++ ){
            scanf("%d", &w[i]);
            sum += w[i];
        }

        for (int i = n; i; i -- ){
        	if (sum % i == 0 && check(sum / i)){
                printf("%d\n", n - i);
                break;
            }
		}  
    }
    
    return 0;
}

